package com.yanqu.road.server.cmd.activity.autoreward.rank;

import com.yanqu.road.entity.enums.activity.chefDuel.eChefDuelActivityType;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.entity.rank.cross.CrossUserRank;
import com.yanqu.road.logic.cross.CrossActivityRankListModel;
import com.yanqu.road.pb.activity.AutoSendRewardProto;
import com.yanqu.road.server.manager.activity.relation.CrossRelationRankMgr;

public class ChefDuelActivityRank extends BaseCrossRank {
    private int childType;

    public ChefDuelActivityRank(int activityId, int childType) {
        super(activityId);
        this.childType = childType;
    }

    @Override
    public AutoSendRewardProto.CrossUserRankMsg.Builder getCrossUserRankMsg() {
        AutoSendRewardProto.CrossUserRankMsg.Builder msg = AutoSendRewardProto.CrossUserRankMsg.newBuilder();
        msg.setActivityId(activityId);
        int conditionType = 0;
        if (childType == eChefDuelActivityType.Phase1.getChildType()) {
            //conditionType = eGamePlayerEventType.CookBoy1IntegralUserCrossRank.getValue();
        } else if (childType == eChefDuelActivityType.Phase2.getChildType()) {
            conditionType = eGamePlayerEventType.ChefDuel2IntegralUserCrossRank.getValue();
        } else if (childType == eChefDuelActivityType.Phase3.getChildType()) {
            conditionType = eGamePlayerEventType.ChefDuel3IntegralUserCrossRank.getValue();
        }
        CrossActivityRankListModel rankListModel = CrossRelationRankMgr.getCrossActivityRankListModel(activityId);
        if (rankListModel != null) {
            int rank = 0;
            for (CrossUserRank rankData : rankListModel.getRankList()) {
                long userId = rankData.getUserId();
                rank++;
                addUserRankData(msg, conditionType, userId, rank);
            }
        }
        //阵营奖励
//        if(childType == eChefDuelActivityType.Phase2.getChildType()){
//            CrossChefDuel2 crossChefDuel2 = CrossChefDuelMgr.getCrossChefDuel2(activityId);
//            if(crossChefDuel2 != null){
//                CampRankListModel model = crossChefDuel2.getCampRankListModel();
//                for (Map.Entry<Long, ChefDuelUpUser> entry : crossChefDuel2.getChefDuelMap().entrySet()) {
//                    ChefDuelUpUser value = entry.getValue();
//                    if(value.getCampId() > 0){
//                        int rank = model.getMyRank(value.getCampId());
//                        addUserRankData(msg, eGamePlayerEventType.ChefDuel2CrossCampRank.getValue(), entry.getKey(), rank);
//                    }
//                }
//            }
//        }
        return msg;
    }

    @Override
    public AutoSendRewardProto.CrossUnionRankMsg.Builder getCrossUnionRankMsg() {
        AutoSendRewardProto.CrossUnionRankMsg.Builder msg = AutoSendRewardProto.CrossUnionRankMsg.newBuilder();
        msg.setActivityId(activityId);
//        int conditionType = 0;
//        if (childType == eActivityCookBoyType.Process1.getChildType()) {
//            conditionType = eGamePlayerEventType.CookBoy1IntegralUnionCrossRank.getValue();
//        }
//        CrossActivityUnionRankListModel rankListModel = CrossRelationRankMgr.getCrossActivityUnionRankListModel(activityId);
//        int rank = 0;
//        if (conditionType != 0) {
//            if (rankListModel != null) {
//                for (UnionActivityRank rankData : rankListModel.getRankList()) {
//                    String unionUid = rankData.getUnionUid();
//                    rank++;
//                    addUnionRankData(msg, conditionType, unionUid, rank);
//                }
//            }
//        }
        return msg;
    }
}
